	package Logicamente;

import java.awt.BorderLayout;
import java.awt.EventQueue;

import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;

import java.awt.GridLayout;

import javax.swing.JButton;
import javax.swing.ImageIcon;

import java.awt.Dimension;
import java.awt.event.ActionListener;
import java.awt.event.ActionEvent;
import java.awt.Insets;

import javax.swing.SwingConstants;
import javax.swing.JLabel;

import java.awt.Toolkit;
import java.awt.GridBagLayout;
import java.awt.GridBagConstraints;
import java.awt.Font;

public class VentanaUsuario extends JFrame {

	private JPanel contentPane;
	
	{
		//Set Look & Feel
		try {
			javax.swing.UIManager.setLookAndFeel("javax.swing.plaf.nimbus.NimbusLookAndFeel");
		} catch(Exception e) {
			e.printStackTrace();
		}
	}

	/**
	 * Launch the application.
	 */
	public static void main(String[] args) {
		EventQueue.invokeLater(new Runnable() {
			public void run() {
				try {
					VentanaUsuario frame = new VentanaUsuario(null);
					frame.setVisible(true);
				} catch (Exception e) {
					e.printStackTrace();
				}
			}
		});
	}

	/**
	 * Create the frame.
	 */
	public VentanaUsuario(final Usuario u) {
		setIconImage(Toolkit.getDefaultToolkit().getImage(VentanaUsuario.class.getResource("/Imagenes/L.png")));
		setTitle("Logicamente");
		setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		setBounds(100, 100, 660, 400);
		contentPane = new JPanelConFondo("/Imagenes/fondo.jpg");
		contentPane.setBorder(new EmptyBorder(5, 5, 5, 5));
		setContentPane(contentPane);
		contentPane.setLayout(new GridLayout(2, 0, 0, 5));
		
		JPanel panel_1 = new JPanelConFondo("/Imagenes/fondo_t.png");
		contentPane.add(panel_1);
		panel_1.setLayout(new BorderLayout(0, 0));
		
		JLabel lblTitulo = new JLabel("");
		lblTitulo.setIcon(new ImageIcon(VentanaUsuario.class.getResource("/Imagenes/etiqueta_titulo_500_f.png")));
		lblTitulo.setHorizontalTextPosition(SwingConstants.CENTER);
		lblTitulo.setHorizontalAlignment(SwingConstants.CENTER);
		panel_1.add(lblTitulo, BorderLayout.CENTER);
		
		JPanel panel = new JPanelConFondo("/Imagenes/fondo_t.png");
		contentPane.add(panel);
		GridBagLayout gbl_panel = new GridBagLayout();
		gbl_panel.columnWidths = new int[]{0, 0, 0, 0, 0, 0, 0};
		gbl_panel.rowHeights = new int[]{0, 0, 0};
		gbl_panel.columnWeights = new double[]{100.0, 50.0, 50.0, 50.0, 50.0, 100.0, Double.MIN_VALUE};
		gbl_panel.rowWeights = new double[]{0.0, 0.0, Double.MIN_VALUE};
		panel.setLayout(gbl_panel);
		
		JLabel lblJugar = new JLabel("Jugar");
		lblJugar.setFont(new Font("DejaVu Sans", Font.BOLD, 12));
		GridBagConstraints gbc_lblJugar = new GridBagConstraints();
		gbc_lblJugar.insets = new Insets(0, 0, 5, 5);
		gbc_lblJugar.gridx = 1;
		gbc_lblJugar.gridy = 0;
		panel.add(lblJugar, gbc_lblJugar);
		
		JLabel lblRanking = new JLabel("Ranking");
		lblRanking.setFont(new Font("DejaVu Sans", Font.BOLD, 12));
		GridBagConstraints gbc_lblRanking = new GridBagConstraints();
		gbc_lblRanking.insets = new Insets(0, 0, 5, 5);
		gbc_lblRanking.gridx = 2;
		gbc_lblRanking.gridy = 0;
		panel.add(lblRanking, gbc_lblRanking);
		
		JLabel lblHistorial = new JLabel("Historial");
		lblHistorial.setFont(new Font("DejaVu Sans", Font.BOLD, 12));
		GridBagConstraints gbc_lblHistorial = new GridBagConstraints();
		gbc_lblHistorial.insets = new Insets(0, 0, 5, 5);
		gbc_lblHistorial.gridx = 3;
		gbc_lblHistorial.gridy = 0;
		panel.add(lblHistorial, gbc_lblHistorial);
		
		JLabel lblComoJugar = new JLabel("Como jugar");
		lblComoJugar.setFont(new Font("DejaVu Sans", Font.BOLD, 12));
		GridBagConstraints gbc_lblComoJugar = new GridBagConstraints();
		gbc_lblComoJugar.insets = new Insets(0, 0, 5, 5);
		gbc_lblComoJugar.gridx = 4;
		gbc_lblComoJugar.gridy = 0;
		panel.add(lblComoJugar, gbc_lblComoJugar);
		
		JButton btnJugar = new JButton("");
		btnJugar.setIcon(new ImageIcon(VentanaUsuario.class.getResource("/Imagenes/boton_jugar_f.png")));
		btnJugar.setPreferredSize(new Dimension(120, 120));
		GridBagConstraints gbc_btnJugar = new GridBagConstraints();
		gbc_btnJugar.insets = new Insets(0, 0, 0, 5);
		gbc_btnJugar.gridx = 1;
		gbc_btnJugar.gridy = 1;
		panel.add(btnJugar, gbc_btnJugar);
		btnJugar.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				actionBtnJugar(arg0,u);
			}
		});

		
		JButton buttonRanking = new JButton("");
		buttonRanking.setIcon(new ImageIcon(VentanaUsuario.class.getResource("/Imagenes/boton_ranking_f.png")));
		buttonRanking.setPreferredSize(new Dimension(120, 120));
		GridBagConstraints gbc_buttonRanking = new GridBagConstraints();
		gbc_buttonRanking.insets = new Insets(0, 0, 0, 5);
		gbc_buttonRanking.gridx = 2;
		gbc_buttonRanking.gridy = 1;
		panel.add(buttonRanking, gbc_buttonRanking);
		buttonRanking.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				actionTabla(arg0,"/Imagenes/tabla_ranking.png");
			}
		});
		
		JButton buttonHistorial = new JButton("");
		buttonHistorial.setPreferredSize(new Dimension(120, 120));
		buttonHistorial.setIcon(new ImageIcon(VentanaUsuario.class.getResource("/Imagenes/boton_historial_f.png")));
		GridBagConstraints gbc_buttonHistorial = new GridBagConstraints();
		gbc_buttonHistorial.insets = new Insets(0, 0, 0, 5);
		gbc_buttonHistorial.gridx = 3;
		gbc_buttonHistorial.gridy = 1;
		panel.add(buttonHistorial, gbc_buttonHistorial);
		buttonHistorial.addActionListener(new ActionListener() {
			public void actionPerformed(ActionEvent arg0) {
				actionTabla(arg0,"/Imagenes/tabla_historial.png");
			}
		});
		
		JButton buttonComoJugar = new JButton("");
		buttonComoJugar.setIcon(new ImageIcon(VentanaUsuario.class.getResource("/Imagenes/boton_ayuda_f.png")));
		buttonComoJugar.setPreferredSize(new Dimension(120, 120));
		GridBagConstraints gbc_buttonComoJugar = new GridBagConstraints();
		gbc_buttonComoJugar.insets = new Insets(0, 0, 0, 5);
		gbc_buttonComoJugar.gridx = 4;
		gbc_buttonComoJugar.gridy = 1;
		panel.add(buttonComoJugar, gbc_buttonComoJugar);
	}
	
	@SuppressWarnings("deprecation")
	protected void actionBtnJugar(ActionEvent arg0,Usuario u) {
		VentanaJugar v = new VentanaJugar(u);
		v.setLocationRelativeTo(null);
		v.setVisible(true);                    
		this.setVisible(false);
		this.hide();
	}
	
	protected void actionTabla(ActionEvent arg0, String imagen) {
		VentanaRankHistRes v = new VentanaRankHistRes(this,imagen);
		v.setLocationRelativeTo(null);
		v.setVisible(true);                    
		this.setVisible(false);
	}
}
